﻿Imports GenericDescriptionLibrary
Imports DevComponents.DotNetBar
Imports DevComponents.AdvTree

Public Class MainForm

    Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        tabStrip1.MdiForm = Me
        DevComponents.DotNetBar.RibbonPredefinedColorSchemes.ChangeOffice2007ColorTable(Me, My.Settings.UIColor)
    End Sub

    Private Sub ButtonItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItemObject.Click
        'create a new document
        Dim doc As frmObjectValue = New frmObjectValue
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
        doc.Text = "New Document " + Me.MdiChildren.Length.ToString()
        For Each myTabItem As TabItem In tabStrip1.Tabs
            Dim myCtl As Control = myTabItem.AttachedControl
            If TypeOf (myCtl) Is frmObjectValue Then
                Dim myFrm As frmObjectValue = CType(myCtl, frmObjectValue)
                If myFrm.Text = doc.Text Then
                    myTabItem.Icon = My.Resources.document_plain
                    Exit For
                End If
            End If
        Next
    End Sub

    Private _formAdmin As frmAdmin
    Public ReadOnly Property formAdmin() As frmAdmin
        Get
            Dim myFrm As frmAdmin = _formAdmin
            If myFrm Is Nothing Then
                myFrm = New frmAdmin
                With myFrm
                    .MdiParent = Me
                    .WindowState = FormWindowState.Maximized
                    .Update()
                    .Name = "frmAdministrator"
                    .Text = "Administration"
                    .Icon = My.Resources.copy
                End With

                For Each myTabItem As TabItem In tabStrip1.Tabs
                    Dim myCtl As Control = myTabItem.AttachedControl
                    If TypeOf (myCtl) Is frmAdmin Then
                        myTabItem.Icon = My.Resources.copy
                        Exit For
                    End If
                Next
                _formAdmin = myFrm
            End If
            Return myFrm
        End Get
    End Property

    Private Sub ButtonItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItemAdmin.Click
        Try
            formAdmin.Show()
            formAdmin.Select()

        Catch ex As Exception
            _formAdmin = Nothing
            formAdmin.Show()
            formAdmin.Select()
        End Try
    End Sub
End Class
